package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocParams;
import org.ycx.doc.dao.model.DocParamsExample;

public interface DocParamsMapper {
    @SelectProvider(type=DocParamsSqlProvider.class, method="countByExample")
    long countByExample(DocParamsExample example);

    @DeleteProvider(type=DocParamsSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocParamsExample example);

    @Delete({
        "delete from doc_params",
        "where PARAM_ID = #{paramId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer paramId);

    @Insert({
        "insert into doc_params (PARAM_ID, PARAM_NAME, ",
        "REQ_POSITION, PARAM_DESC, ",
        "REQ_RESP, PARAM_TYPES, ",
        "PARAM_NOTES, PARAM_MOCK, ",
        "PARAM_VERSION, CREATE_TS, ",
        "CREATE_UID, UPDATE_TS, ",
        "UPDATE_UID, STATES, ",
        "PID)",
        "values (#{paramId,jdbcType=INTEGER}, #{paramName,jdbcType=VARCHAR}, ",
        "#{reqPosition,jdbcType=INTEGER}, #{paramDesc,jdbcType=VARCHAR}, ",
        "#{reqResp,jdbcType=INTEGER}, #{paramTypes,jdbcType=INTEGER}, ",
        "#{paramNotes,jdbcType=VARCHAR}, #{paramMock,jdbcType=VARCHAR}, ",
        "#{paramVersion,jdbcType=INTEGER}, #{createTs,jdbcType=DATE}, ",
        "#{createUid,jdbcType=INTEGER}, #{updateTs,jdbcType=DATE}, ",
        "#{updateUid,jdbcType=INTEGER}, #{states,jdbcType=INTEGER}, ",
        "#{pid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="moduleId", before=false, resultType=Integer.class)
    int insert(DocParams record);

    @InsertProvider(type=DocParamsSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="moduleId", before=false, resultType=Integer.class)
    int insertSelective(DocParams record);

    @SelectProvider(type=DocParamsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="PARAM_ID", property="paramId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="MODULE_ID", property="moduleId", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_NAME", property="paramName", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQ_POSITION", property="reqPosition", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_DESC", property="paramDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQ_RESP", property="reqResp", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_TYPES", property="paramTypes", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_NOTES", property="paramNotes", jdbcType=JdbcType.VARCHAR),
        @Result(column="PARAM_MOCK", property="paramMock", jdbcType=JdbcType.VARCHAR),
        @Result(column="PARAM_VERSION", property="paramVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER),
        @Result(column="STATES", property="states", jdbcType=JdbcType.INTEGER),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER)
    })
    List<DocParams> selectByExample(DocParamsExample example);

    @Select({
        "select",
        "PARAM_ID, MODULE_ID, PARAM_NAME, REQ_POSITION, PARAM_DESC, REQ_RESP, PARAM_TYPES, ",
        "PARAM_NOTES, PARAM_MOCK, PARAM_VERSION, CREATE_TS, CREATE_UID, UPDATE_TS, UPDATE_UID, ",
        "STATES, PID",
        "from doc_params",
        "where PARAM_ID = #{paramId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="PARAM_ID", property="paramId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="MODULE_ID", property="moduleId", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_NAME", property="paramName", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQ_POSITION", property="reqPosition", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_DESC", property="paramDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQ_RESP", property="reqResp", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_TYPES", property="paramTypes", jdbcType=JdbcType.INTEGER),
        @Result(column="PARAM_NOTES", property="paramNotes", jdbcType=JdbcType.VARCHAR),
        @Result(column="PARAM_MOCK", property="paramMock", jdbcType=JdbcType.VARCHAR),
        @Result(column="PARAM_VERSION", property="paramVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER),
        @Result(column="STATES", property="states", jdbcType=JdbcType.INTEGER),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER)
    })
    DocParams selectByPrimaryKey(Integer paramId);

    @UpdateProvider(type=DocParamsSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocParams record, @Param("example") DocParamsExample example);

    @UpdateProvider(type=DocParamsSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocParams record, @Param("example") DocParamsExample example);

    @UpdateProvider(type=DocParamsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocParams record);

    @Update({
        "update doc_params",
        "set MODULE_ID = #{moduleId,jdbcType=INTEGER},",
          "PARAM_NAME = #{paramName,jdbcType=VARCHAR},",
          "REQ_POSITION = #{reqPosition,jdbcType=INTEGER},",
          "PARAM_DESC = #{paramDesc,jdbcType=VARCHAR},",
          "REQ_RESP = #{reqResp,jdbcType=INTEGER},",
          "PARAM_TYPES = #{paramTypes,jdbcType=INTEGER},",
          "PARAM_NOTES = #{paramNotes,jdbcType=VARCHAR},",
          "PARAM_MOCK = #{paramMock,jdbcType=VARCHAR},",
          "PARAM_VERSION = #{paramVersion,jdbcType=INTEGER},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER},",
          "STATES = #{states,jdbcType=INTEGER},",
          "PID = #{pid,jdbcType=INTEGER}",
        "where PARAM_ID = #{paramId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocParams record);
}